package com.brower.project

import com.brower.project.utils.GsonUtils
import com.brower.project.bean.UserInfoBean
import com.brower.project.utils.CookiePreferences
import com.tencent.mmkv.MMKV

private const val SAVE_USER = "save_user"
fun isLogin() = CookiePreferences.getCookie() != null
class CommonExt {
    companion object {
        @JvmStatic
        fun isLogin(): Boolean {
            return CookiePreferences.getCookie() != null
        }

        @JvmStatic
        fun clearCookie() {
            CookiePreferences.clearCookie()
        }

        @JvmStatic
        fun saveUser(userJson: String) {
            MMKV.defaultMMKV().putString(SAVE_USER, userJson)
        }

        @JvmStatic
        fun getUser(): UserInfoBean {
            val string = MMKV.defaultMMKV().getString(SAVE_USER, "")
            return GsonUtils.fromJson(string, UserInfoBean::class.java)
        }
    }
}


